package org.vy.app.ajax.service.metadata;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.vy.app.ajax.IService;
import org.vy.dal.dao.lookup.VyLookupQualificationDAO;
import org.vy.dal.dao.lookup.VyLookupQualificationDO;

public class QualificationMetaService implements IService<QualificationMetaResponse> {

	@Override
	public QualificationMetaResponse execute(Map<String, String> params, HttpServletRequest request) {
		QualificationMetaResponse rsp = new QualificationMetaResponse();
		try{
			VyLookupQualificationDO dto = new VyLookupQualificationDO();
			dto.setQualificationCode("%");
			List<VyLookupQualificationDO> qualifications = VyLookupQualificationDAO.findByParam(dto);
			rsp.setQualification(getQualificationMap(qualifications));
		}catch(Exception e){
			e.printStackTrace();
		}
		return rsp;
	}
	
	private Map<String, String> getQualificationMap(List<VyLookupQualificationDO> lst){
		Map<String, String> map = new HashMap<String, String>();
		for(VyLookupQualificationDO rec : lst){
			map.put(rec.getQualificationName(), rec.getQualificationCode());
		}
		return map;
	}
}
